package com.appspot.finajjarane.ws.rest;

import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.appspot.finajjarane.framework.models.ArticleModel;
import com.appspot.finajjarane.framework.service.IArticleService;
import com.sun.jersey.api.spring.Autowire;




@Path("articles")
@Component
@Scope(BeanDefinition.SCOPE_SINGLETON)
@Autowire
public class WSArticles {


	@Autowired
	private IArticleService iArticleService;


	@GET
	@Path("/{number}/{lang}")
	@Produces(MediaType.APPLICATION_JSON)
	public List<ArticleModel> art(
									@PathParam("number") final int total,
									@PathParam("lang") final String lang
								){

		try {
			return iArticleService.getArticlesList(1, total, lang);
		} catch (Exception e) {
			return new ArrayList<ArticleModel>();
		}

	}

}
